home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / public / RTF / test / Rich_Text_Format_Specs < prev    next >
Text File  |  1994-08-01  |  13KB  |  369 lines

  1. Specification for RTF
  2. ---------------------
  3.  
  4. RTF text is a form of encoding of various text formatting properties,
  5. document structures, and document properties,
  6. using the printable ASCII character set. Special characters can be also
  7. thus encoded, although RTF does not prevent the utilization of character
  8. codes outside the ASCII printable set.
  9.  
  10. The main encoding mechanism of "control words" provides a name space that
  11. may be later used to expand the realm of RTF with macros, programming, etc.
  12.  
  13. 1. BASIC INGREDIENTS
  14.  
  15. Control words are of the form:
  16.     \lettersequence <delimiter>
  17. where <delimiter>. is:
  18.     . a space: the space is part of the control word.
  19.     . a digit or - means that a parameter follows. The following digit
  20.         sequence is then delimited by a space or any other
  21.         non-letter-or-digit as for control words.
  22.     . any other non-letter-or digit: terminates the control word, but is not
  23.         a part of the control word.
  24.  
  25. By "letter:, here we mean just the upper and lower case ASCII letters.
  26.  
  27. Control symbols consist of a \ character followed by a single nonletter.
  28. They require no further delimiting.
  29.  
  30.     Notes: control symbols are compact, but there are not too many
  31.     of them. The number of possible control words are not limited.
  32.     The parameter is partially incorporated in control symbols, so that
  33.     a program that does not understand a control symbol can recognize
  34.     and ignore the corresponding parameter as well.
  35.  
  36. In addition to control words and control symbols, there are also the braces:
  37.     {       group start, and
  38.     }       group end.
  39. The text grouping will be used for formatting and to delineate document
  40. structure - such as the footnotes, headers, title, and so on.
  41. The control words, control symbols, and braces constitute control information.
  42. All other characters in RTF text constitute "plain text".
  43.  
  44. Since the characters \, {, and } have specific uses in RFT, the control
  45. symbols \\,\{, and \} are provided to express the corresponding plain
  46. characters.
  47.  
  48.  
  49. 2. WHAT RFT TEXT MEANS (SEMANTICS)
  50.  
  51. The reader of a RFT stream will be concerned with:
  52.     Separating control information from plain text.
  53.     Acting on control information. This is designed to be
  54.         a relatively simple process, as described below.
  55.                 Some control information just contributes special
  56.                 characters to the plain text stream.  Other information
  57.         serves to change the "program state" which includes
  58.         properties of the document as a whole and also a stack
  59.         of "group states" that apply to parts.
  60.                 Note that the group state is saved by the { brace and is
  61.         restored by the } brace. The current group state specifies:
  62.         1. the "destination" or part of the document that the
  63.             plain text is building up.
  64.         2. the character formatting properties - such as bold or
  65.             italic.
  66.         3. the paragraph formatting properties - such as justified.
  67.         4. the section formatting properties - such as number of
  68.             columns.
  69.     Collecting and properly disposing of the remaining "plain text"
  70.         as directed by the current group state.
  71.  
  72. In practice the RFT reader will proceed as follows:
  73.     0. read next char
  74.     1. if ={
  75.         stack current state. current state does not change.
  76.         continue.
  77.     2. if =}
  78.         unstack current state from stack. this will change the
  79.         state in general.
  80.     3. if =\
  81.         collect control word/control symbol and parameter, if any.
  82.         look up word/symbol in symbol table (a constant table)
  83.         and act according to the description there. The different
  84.         actions are listed below. Parameter is left available
  85.                 for use by the action.  Leave read pointer before or after
  86.                 the delimiter, as appropriate.  After the action, continue.
  87.     4. otherwise, write "plain text" character to current destination
  88.         using current formatting properties.
  89.  
  90. Given a symbol table etry, the possible actions are as follows:
  91.     A. Change destination:
  92.         change destination to the destination described in the entry.
  93.         Most destination changes are legal only immediately after a {. Other restrictions
  94.         may also apply (for example, footnotes may not be nested.)
  95.     B. Change formatting property:
  96.         The symbol table entry will describe the property and
  97.         whether the parameter is required.
  98.     C. Special character:
  99.         The symbol table entry will describe the character code..
  100.         goto 4.
  101.     D. End of paragraph
  102.         This could be viewed as just a special character.
  103.     E. End of section
  104.         This could be viewed as just a special character.
  105.     F. Ignore
  106.  
  107. 3. SPECIAL CHARACTERS
  108.  
  109. The special characters are explained as they exist in Mac Word. Clearly,
  110. other characters may be added for interchange with other programs. If
  111. a character name is not recognized by a reader, according to the rules
  112. described above, it will be simply ignored.
  113.  
  114.     \chpgn          current page number (as in headers)
  115.     \chftn          auto numbered footnote reference
  116.             (footnote to follow in a group)
  117.     \chpict         placeholder character for picture
  118.             (picture to follow in a group)
  119.     \chdate         current date (as in headers)
  120.     \chtime         current time (as in headers)
  121.     \|              formula character
  122.     \~              non-breaking space
  123.     \-              non-required hyphen
  124.     \_              non-breaking hyphen
  125.  
  126.     \page           required page break
  127.     \line           required line break (no paragraph break)
  128.  
  129.     \par            end of paragraph.
  130.     \sect           end of section and end of paragraph.
  131.     \tab            same as ASCII 9
  132.  
  133. For simplicity of opertation, the ASCII codes 9 and 10 will be accepted
  134. as \tab and \par respectively. ASCII 13 will be ignored. The control
  135. code \<10> will be ignored. It may be used to include "soft"
  136. carriage returns for easier readibility but which will have no effect
  137. on the interpretation.
  138.  
  139. 4. DESTINATIONS
  140.  
  141. The change of destination will reset all properties to default.
  142. Changes are legal only at the beginning of a group (by group here
  143. we mean the text and controls enclosed in braces.)
  144.  
  145.     \rtf<param>
  146.         The destination is the document. The parameter is the
  147.         version number of the writer. This destination preceded
  148.         by { the beginnings of RTF documents and the corresponding }
  149.         marks the end.
  150.         Legal only once after the initial {.
  151.                 Small scale interchange of RTF where other methods for
  152.                 marking the end of string are available, as in a string
  153.                 constant, need not include this identification but will
  154.                 start with this destination as the default.
  155.     \pict
  156.         The destination is a picture. The group must immediately
  157.         follow a \chpict character. The plain text describes
  158.         the picture as a hex dump (string of characters 0,1,...
  159.         9, a, ..., e, f.)
  160.         (Formatting properties to determine data interpretation,
  161.         size)
  162.     \footnote
  163.         The destination is a footnote text. The group must
  164.         immediately follow the footntoe reference character(s).
  165.     \header
  166.         The destination is the header text for the current section.
  167.         The group must precede the first plain text character
  168.         in the section.
  169.     \headerl
  170.         Same as above, but header for left-hand pages.
  171.     \headerr
  172.         Same as above, but header for right-hand pages.
  173.     \headerf
  174.         Same as above, but header for first page.
  175.     \footer
  176.         Same as above, but footer.
  177.     \footerl
  178.         Same as above, but footer for left-hand pages.
  179.     \footerr
  180.         Same as above, but footer for right-hand pages.
  181.     \footerf
  182.         Same as above, but header for first page.
  183.     \ftnsep
  184.         Same as above, but text is footnote separator
  185.     \ftnsepc
  186.         Same as above, but text is separator for continued footnotes.
  187.     \ftncn
  188.         Same as above, but text is continued footnote notice.
  189.     \info
  190.         text is information block for the document. Parts of the
  191.         text is further classified by "properties" of the text
  192.         that are listed below - such as "title". These are not
  193.         formatting properties, but a device to delimit and identify
  194.         parts of the info from the text in the group.
  195.     \stylesheet
  196.         text is the style sheet for the document.
  197.         More precisely, text between semicolons are taken to be
  198.         style names which will be defined to stand for the
  199.         formatting properties which are in effect.
  200.     \fonttbl
  201.         font table. See below.
  202.     \colortbl
  203.         color table. See below.
  204.     \comment
  205.         text will be ignored.
  206.  
  207. 5. DOCUMENT FORMATTING PROPERTIES
  208.  
  209. (000 stands for a number which may be signed)
  210.  
  211.     \paperw000      paper width in twips            12240
  212.     \paperh000      paper height                    15840
  213.     \margl000       left margin                     1800
  214.     \margr000       right margin                    1800
  215.     \margt000       top margin                      1440
  216.     \margb000       bottom margin                   1440
  217.     \facingp        facing pages
  218.     \gutter000      gutter width
  219.     \deftab000      default tab width               720
  220.     \widowctrl      enable widow control
  221.  
  222.     \endnotes       footnotes at end of section
  223.     \ftnbj          footnotes at bottom of page     default
  224.     \ftntj          footnotes beneath text (top just)
  225.  
  226.     \ftnstart000    starting footnote number        1
  227.     \ftnrestart     restart footnote numbers each page
  228.     \pgnstart000    starting page number            1
  229.     \linestart000   starting line number            1
  230.     \landscape      printed in landscape format
  231.  
  232. (the "next file" property will be encoded in the info text )
  233.  
  234.  
  235. 6. SECTION FORMATTING PROPERTIES
  236.     \sectd          reset to default section properties
  237.  
  238.     \nobreak        break code
  239.     \colbreak       break code                      default
  240.     \pagebreak      break code
  241.     \evenbreak      break code
  242.     \oddbreak       break code
  243.     \pgnrestart     restart page numbers at 1
  244.  
  245.     \pgndec         page number format decimal      default
  246.     \pgnucrm        page number format uc roman
  247.     \pgnlcrm        page number format lc roman
  248.     \pgnucltr       page number format uc letter
  249.     \pgnlcltr       page number format lc letter
  250.  
  251.     \pgnx000        auto page number x pos          720
  252.     \pgny000        auto page number y pos          720
  253.     \linemod000     line number modulus
  254.     \linex000       line number - text distance     360
  255.  
  256.     \linerestart    line number restart at 1        default
  257.     \lineppage      line number restart on each page
  258.     \linecont       line number continued from prev section
  259.  
  260.     \headery000     header y position from top of page      720
  261.     \footery000     footer y position from bottom of page   720
  262.  
  263.     \cols000        number of columns               1
  264.     \colsx000       space between columns           720
  265.     \endnhere       include endnotes in this section
  266.     \titlepg        title page is special
  267.  
  268.  
  269. 7. PARAGRAPH FORMATTING PROPERTIES
  270.  
  271.     \pard           dreset to default para properties.
  272.     \s000           style
  273.  
  274.     \ql             quad left                       default
  275.     \ql             right
  276.     \qj             justified
  277.     \qc             centered
  278.  
  279.     \fi000          first line indent
  280.     \li000          left indent
  281.     \ri000          right indent
  282.     \sb000          space before
  283.     \sa000          space after
  284.     \sl000          space between lines
  285.  
  286.     \keep           keep
  287.     \keepn          keep with next para
  288.     \sbys           side by side
  289.     \pagebb         page break before
  290.     \noline         no line numbering
  291.  
  292.     \brdrt          border top
  293.     \brdrb          border bottom
  294.     \brdrl          border left
  295.     \brdrr          border right
  296.     \box            border all around
  297.  
  298.     \brdrs          single thickness
  299.     \brdrth         thick
  300.     \brdrsh         shadow
  301.     \brdrdb         double
  302.  
  303.     \tx000          tab position
  304.     \tqr            right flush tab (these apply to last specified pos)
  305.     \tqc            centered tab
  306.     \tqdec          decimal aligned tab
  307.     \tldot          leader dots
  308.     \tlhyph         leader hyphens
  309.     \tlul           leader underscore
  310.     \tlth           leader thick line
  311.  
  312.  
  313. 8. CHARACTER FORMATTING PROPERTIES
  314.  
  315.     \plain          reset to default text properties.
  316.  
  317.     \b              bold
  318.     \i              italic
  319.     \strike         strikethrough
  320.     \outl           outline
  321.     \shad           shadow
  322.     \scaps          small caps
  323.     \caps           all caps
  324.     \v              invisible text
  325.     \f000           font number n
  326.     \fs000          font size in half points        24
  327.  
  328.     \ul             underline
  329.     \ulw            word underline
  330.     \uld            dotted underline
  331.     \uldb           double underline
  332.  
  333.     \up000          superscript in half points
  334.     \dn000          subscript in half points
  335.  
  336. 9. INFO GROUP
  337.  
  338. The plain text in the group is used to sepcify the various fields of
  339. the information block. The current field may be thought of as a
  340. particular setting of the "sub-destination" property of the text..
  341.     \title          following plain text is the title
  342.     \subject        following text is the subject
  343.     \operator
  344.     \author
  345.     \keywords
  346.     \doccomm        comments (not to be cofused with \comment )
  347.     \version
  348.     \nextfile       following text is name of "next" file
  349.  
  350. The other properties assign their parameters directly to the info block.
  351.     \verno000       internal version number
  352.     \creatim        creation time follows
  353.  
  354.     \yr000          year to be assigned to previously specified time field
  355.     \mo000
  356.     \dy000
  357.     \hr000
  358.     \min000
  359.     \sec000
  360.  
  361.     \revtim         revision time follows
  362.     \printtim       print time follows
  363.     \buptim         backup time follows
  364.  
  365.     \edmins00       editing minutes
  366.     \nofpages000
  367.     \nofwords000
  368.     \noofchars000
  369.     \id000          internal id number